<?php

/**
 * Description of actionsAdm
 *
 * @author MariiTeheran
 */
require_once 'conexion.php';
require_once 'objects/race.php';
require_once 'objects/disease.php';
require_once 'objects/food.php';

class actionsAdm {
    
    private $conx;
    private $race = "SELECT max(racecod) FROM RACE";
    private $racenum = 0;
    private $disease = "SELECT max(diseasecod) FROM DISEASE";
    private $diseasenum = 0;
    private $food = "SELECT max(foodcod) FROM FOOD";
    private $foodnum = 0;

    private function __construct() {
        $this->conx = null;
    }
    
    public function thisrace(){
        $consult = sprintf($this->race, $num);
        $this->conx = new conexion();
        $result = pg_exec($this->conx->getConexionDB(), $consult);
        $this->conx->closeConexionDB();
        $this->conx = null;
        $date = pg_fetch_assoc($result);
        $val = $date['max'];
        if($val == " "){
            $this->racenum = 1;
        } else {
            $this->racenum = $val + 1;
        }
        return $this->racenum;
    }
    
    public function thisdisease(){
        $consult = sprintf($this->disease, $num);
        $this->conx = new conexion();
        $result = pg_exec($this->conx->getConexionDB(), $consult);
        $this->conx->closeConexionDB();
        $this->conx = null;
        $date = pg_fetch_assoc($result);
        $val = $date['max'];
        if($val == " "){
            $this->diseasenum = 1;
        } else {
            $this->diseasenum = $val + 1;
        }
        return $this->diseasenum;
    }
    
    public function thisfood(){
        $consult = sprintf($this->food, $num);
        $this->conx = new conexion();
        $result = pg_exec($this->conx->getConexionDB(), $consult);
        $this->conx->closeConexionDB();
        $this->conx = null;
        $date = pg_fetch_assoc($result);
        $val = $date['max'];
        if($val == " "){
            $this->foodnum = 1;
        } else {
            $this->foodnum = $val + 1;
        }
        return $this->foodnum;
    }
    
}

?>
